package variable

def a = 1.23
def result
switch(a) {
    case "foo":
     result = 'found foo'  
     break
    case 'bar':
     result = 'bar'
     break 
    case [1.23,4,5,6,'inList']: //列表
     result = 'list'
     break
    case 12..30:
     result = 'range' // 范围
     break
    case Integer:
     result = 'Integer'
     break
    case BigDecimal:
     result = 'big decimal'
     break
    default: result = 'default'
}

println result

//对范围的for循环
def sum = 0
for (i in 0..9){
    sum += i
}

sum = 0 

//对List循环
for (i in [1,2,3,4,5,6,7,8,9]){
    sum += i 
}
//对map循环
for(i in ['lili':1, 'luck': 2,'xiaoming': 3]){
    sum += i.value
}

println sum

